package com.yuyou.fn.provider.aop;

import com.yuyou.fn.api.exception.ApiServiceException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Aspect
public class ExposeServiceAspect {

    private final static Logger log  = LoggerFactory.getLogger("provider-service");

    @AfterThrowing(throwing="ex",pointcut="execution(* com.yuyou.fn.provider.impl.*.*(..))")
    public void handleException(JoinPoint joinPoint , Throwable ex ){
        log.error(joinPoint.toString(), ex );
        throw new ApiServiceException(ex.getMessage()) ;
    }
}
